import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BaseinfoChatApi } from '#/api/csyt/baseinfochat';
import type { BaseinfoDemandApi } from '#/api/csyt/baseinfodemand';

import { getRangePickerDefaultProps } from '#/utils';
// import {OnActionClickFn} from "#/adapter/vxe-table";

// import {BaseinfoDemandApi} from "#/api/csyt/baseinfodemand";

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'chatNo',
      label: '会话编号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入回话编号',
      },
    },
    {
      fieldName: 'chatName',
      label: '会话名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入回话编号',
      },
    },
    {
      fieldName: 'demandNo',
      label: '需求方',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需求方',
      },
    },
    {
      fieldName: 'demandName',
      label: '需求名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需求方',
      },
    },
    {
      fieldName: 'demandCompany',
      label: '需方企业',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需求方',
      },
    },
    {
      fieldName: 'demandPhone',
      label: '需方联系方式',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需求方',
      },
    },
    {
      fieldName: 'productNo',
      label: '产品编号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入产品方',
      },
    },
    {
      fieldName: 'productName',
      label: '供方名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入产品方',
      },
    },
    {
      fieldName: 'productCompany',
      label: '供方企业',
      component: 'Input',
      componentProps: {
        placeholder: '请输入产品方',
      },
    },
  ];
}
export function useFormQuery(): VbenFormSchema[] {
  return [
    {
      fieldName: 'chatName',
      label: '会话名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入会话名称',
        readOnly: true,
      },
    },
    {
      fieldName: 'chatNo',
      label: '会话编号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入会话编号',
        readOnly: true,
      },
    },
    {
      fieldName: 'productCompany',
      label: '供方企业',
      component: 'Input',
      componentProps: {
        placeholder: '请输入供方企业',
        readOnly: true,
      },
    },
    {
      fieldName: 'demandCompany',
      label: '需方企业',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需方企业',
      },
    },
  ];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'chatNo',
      label: '会话编号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入回话编号',
      },
    },
    {
      fieldName: 'demandNo',
      label: '需求编号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入需求方',
      },
    },
    {
      fieldName: 'productNo',
      label: '产品编号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入产品方',
      },
    },
    // {
    //   fieldName: 'demandIndicator',
    //   label: '需求指标',
    //   component: 'Input',
    //   componentProps: {
    //     allowClear: true,
    //     placeholder: '请输入需求指标',
    //   },
    // },
    // {
    //   fieldName: 'productLableinfo',
    //   label: '产品标签',
    //   component: 'Select',
    //   componentProps: {
    //     allowClear: true,
    //     options: [],
    //     placeholder: '请选择产品标签',
    //   },
    // },
    // {
    //   fieldName: 'demaToProd',
    //   label: '是否需求发起',
    //   component: 'Select',
    //   componentProps: {
    //     allowClear: true,
    //     options: [],
    //     placeholder: '请选择是否需求发起',
    //   },
    // },
    // {
    //   fieldName: 'status',
    //   label: '状态',
    //   component: 'Select',
    //   componentProps: {
    //     allowClear: true,
    //     options: [],
    //     placeholder: '请选择状态',
    //   },
    // },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BaseinfoChatApi.BaseinfoChat>['columns'] {
  return [
    { type: 'checkbox', width: 40 },
    {
      field: 'id',
      title: '序号',
      minWidth: 120,
    },
    {
      field: 'chatNo',
      title: '会话编号',
      minWidth: 120,
      slots: { default: 'hui-url' },
    },
    {
      field: 'chatName',
      title: '会话名称',
      minWidth: 120,
    },
    // {
    //   field: 'demandNo',
    //   title: '需求方',
    //   minWidth: 120,
    // },
    {
      field: 'demandName',
      title: '需求名称',
      minWidth: 120,
    },
    // {
    //   field: 'productNo',
    //   title: '产品方',
    //   minWidth: 120,
    // },
    {
      field: 'productName',
      title: '产品名称',
      minWidth: 120,
    },
    {
      field: 'demaPhone',
      title: '需方联系方式',
      minWidth: 120,
    },
    {
      field: 'demandCompany',
      title: '需方企业',
      minWidth: 120,
    },
    {
      field: 'productCompany',
      title: '供方企业',
      minWidth: 120,
    },
    {
      field: '',
      title: '发起方',
      minWidth: 120,
    },
    // {
    //   field: 'demandIndicator',
    //   title: '需求指标',
    //   minWidth: 120,
    // },
    // {
    //   field: 'productLableinfo',
    //   title: '产品标签',
    //   minWidth: 120,
    // },
    // {
    //   field: 'demaToProd',
    //   title: '是否需求发起',
    //   minWidth: 120,
    // },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

export function useBaseinfoIndicatorGridEditColumns(
  onActionClick?: OnActionClickFn<BaseinfoDemandApi.BaseinfoIndicator>,
): VxeTableGridOptions<BaseinfoDemandApi.BaseinfoIndicator>['columns'] {
  return [
    {
      field: 'id',
      title: '序号',
      minWidth: 60,
      slots: { default: 'id' },
    },
    {
      field: 'ruleName',
      title: '规则名称',
      minWidth: 120,
      slots: { default: 'ruleName' },
    },
    {
      field: 'ruleDescription',
      title: '规则描述',
      minWidth: 120,
      slots: { default: 'ruleDescription' },
    },
    {
      field: 'targetNo',
      title: '指标编码',
      minWidth: 120,
      slots: { default: 'targetNo' },
    },
    {
      field: 'targetName',
      title: '指标名称',
      minWidth: 120,
      slots: { default: 'targetName' },
    },
    {
      field: 'targetDescription',
      title: '指标描述',
      minWidth: 120,
      slots: { default: 'targetDescription' },
    },
    {
      field: 'operation',
      title: '操作',
      minWidth: 180,
      align: 'center',
      fixed: 'right',
      showOverflow: false,
      cellRender: {
        attrs: {
          nameField: 'id',
          nameTitle: '指标',
          onClick: onActionClick,
        },
        name: 'CellOperation',
        options: [
          {
            code: 'delete',
            show: true,
          },
        ],
      },
    },
  ];
}
